FROM php:7.3.25-fpm-alpine3.12
MAINTAINER "ZYL" <1577121881@qq.com>

# COPY repositories /etc/apk/repositories

# The main mirrors are giving us timeout issues on builds periodically.
# So we can try these.
ENV TZ=Asia/Shanghai

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
    && apk update \
    && apk upgrade \
    && apk add --no-cache bash bash-doc bash-completion \
    && apk add --no-cache supervisor openssl-dev openssl \
    && apk add --no-cache  tzdata zeromq \
    && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
    && docker-php-ext-install mbstring opcache pdo_mysql mysqli iconv \
    # nginx
    && apk add --no-cache nginx && mkdir /run/nginx/ \
    # bzip2
    && apk add --no-cache bzip2-dev && docker-php-ext-install bz2 \
    # gd
    && set -ex \
    && apk add --no-cache libpng-dev libjpeg-turbo-dev freetype-dev \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install gd \
    # mcrypt
    && apk add --no-cache -t .build autoconf g++ make \
    && apk add --no-cache libmcrypt-dev \
    && pecl install mcrypt \
    && docker-php-ext-enable mcrypt \
    && apk del .build \
    # Redis
    && apk add --no-cache --virtual .build-deps g++ make autoconf \
    && pecl install redis \
    && docker-php-ext-enable redis \
    && apk del .build-deps \
    # Zip
    && apk add --no-cache zlib-dev libzip-dev \
    && docker-php-ext-install zip \
    # bcmath
    && docker-php-ext-install -j$(nproc) bcmath \
    # Imagick
    && apk add --no-cache -t .build g++ make autoconf \
    && apk add --no-cache libtool imagemagick-dev libgomp \
    && pecl install imagick \
    && docker-php-ext-enable imagick \
    # swoole4
    && pecl install swoole \
    && docker-php-ext-enable swoole \
    && apk del .build \
    && rm -rf /var/cache/apk/*
